<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>lottery</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body, html {
            width: 100%;
            height: 100%;
        }

        .wrap {
            width: 100%;
            height: 100%;
            position: relative;
        }

        .wrap .lottery-box {
            position: relative;
            overflow: hidden;
        }

        .wrap .lottery-box #lottery-btn-img {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 80px;
            height: 80px;
            background: url("./images/start.png") no-repeat;
            background-size: 100% 100%;
        }

        #rotate-img {
            transform: rotate(0deg);
        }

        .btn {
            display: block;
            padding: 10px 20px;
            margin: 20px auto;
        }
    </style>
</head>
<body>
<div class="wrap">
    <div class="lottery-box">
        <img src="./images/rotate.jpg" alt="点击中心抽奖" width="100%" id="rotate-img">
        <div id="lottery-btn-img"></div>
    </div>
    <button id="reset-deg-btn" class="btn">重置角度</button>
    <button id="reset-params-btn" class="btn">重置参数</button>
</div>
</body>
<script src="./lottery.js"></script>
<script>
    var myLottery = Lottery(['1000元', '50元', '5元', '谢谢参与', '第二个5元'])

    document.querySelector('#lottery-btn-img').onclick = () => {
        var result, toast;

        myLottery.rotate(function () {
            result = myLottery.result == '第二个5元' ? '5元' : myLottery.result
            toast = myLottery.result == '谢谢参与' ? '谢谢参与' : '恭喜您获得' + result + '奖金'
            console.log(toast)
        })
    }

    document.querySelector('#reset-deg-btn').onclick = () => {
        myLottery.resetDeg(
            myLottery.rotate()
        )
    }

    document.querySelector('#reset-params-btn').onclick = () => {
        myLottery.resetParams({'1000元': 0.1, '50元': 0, '5元': 0, '谢谢参与': 0.9, '第二个5元': 0})
        console.log(myLottery)
    }
</script>
</html>